import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.util.Random;

public class DeckPile extends CardPile {
	DeckPile(int x, int y) {
		super(x, y);
		for (int i = 0; i < 4; i++)
			for (int j = 0; j <= 12; j++)
				addCard(new Card(i, j));
		Random generator = new Random();
		for (int i = 0; i < 52; i++) {
			int j = Math.abs(generator.nextInt() % 52);
			// swap the two card values
			Object temp = thePile.elementAt(i);
			thePile.setElementAt(thePile.elementAt(j), i);
			thePile.setElementAt(temp, j);
		}
	}

	public void select() {
		if (Solitaire.deckPile.top() == null) {
			while(!Solitaire.discardPile.isEmpty()){
				Solitaire.deckPile.addCard(Solitaire.discardPile.pop());
			};
		} else {
			
			Solitaire.discardPile.addCard(Solitaire.deckPile.pop());
		}
	}

}
